package com.sina.util;

import android.util.Log;

/**
 * Created by IntelliJ IDEA.
 * User: qtang
 * Date: Jul 4, 2013
 * Time: 2:08:48 PM
 * To change this template use File | Settings | File Templates.
 */
public class StringUtil {
	public static final String LOG_TAG = "StringUtil";
	
    public static String transferArray2String(String[] stockCodes) {
        if (stockCodes == null || stockCodes.length == 0) {
            return null;
        }
        StringBuilder sb = new StringBuilder(stockCodes[0]);
        final int length = stockCodes.length;
        for (int i = 1; i != length; ++i) {
            sb.append(',');
            sb.append(stockCodes[i]);
        }
        
        Log.i(LOG_TAG,sb.toString());
        return sb.toString();
    }
    
    public static String formatData2Deci(double c) {
        java.text.DecimalFormat myformat = new java.text.DecimalFormat("#0.00");
        return myformat.format(c);
    }
    
    public static String formatData4Deci(double c) {
        java.text.DecimalFormat myformat = new java.text.DecimalFormat("#0.0000");
        return myformat.format(c);
    }
    
    public static double getDiscount(double value, double price){
    	return 100 * (value - price)/value;
    }
    
    public static String transferCode(String fundCode){
    	return fundCode.replaceAll("sz", "jj").replaceAll("sh", "jj");
    }
    
}
